<?php

namespace App\Admin\Forms;

use App\Models\Vip;
use Dcat\Admin\Widgets\Form;

class RegForm extends Form
{
    /**
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    public function handle(array $input)
    {
        // dump($input);
        admin_setting($input);
        // return $this->response()->error('Your error message.');

        return $this
				->response()
				->success('保存成功')
				->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $vips = Vip::pluck('name', 'id')->toArray();
        $this->select('Default_vip', '默认会员等级')->options($vips)->default(admin_setting('Default_vip','1'));
        $this->number('Default_domain', '注册赠送域名额度')->default(admin_setting('Default_domain','0'));
        $this->number('Default_forward', '注册赠送转发额度')->default(admin_setting('Default_forward','10'));
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function default()
    {
        return [
            'recharge'  => admin_setting('recharge')

        ];
    }
}
